// Query view implementation
use iced::{Element, widget::{column, row, text_input, button, text, scrollable}};

/// Query view component
pub fn query_view<'a, Message>(
    query: &'a str,
    result: &'a str,
    on_query_change: impl Fn(String) -> Message + 'a,
    on_execute: Message,
) -> Element<'a, Message>
where
    Message: Clone + 'a,
{
    let query_input = text_input("Enter your SQL query...", query)
        .on_input(on_query_change);

    let execute_button = button(text("Execute"))
        .on_press(on_execute);

    let result_display = scrollable(text(result));

    column![
        row![query_input, execute_button].spacing(10),
        result_display
    ]
    .spacing(10)
    .into()
}
